package cn.memset.code.stream;

import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class MapExample {
    public static void main(String[] args) {
        mapStream();
    }

    public static void mapStream() {
        List<String> words = Arrays.asList("hello", "world", "I", "love", "you");
        words.stream()
                .map(String::length)
                .forEach(System.out::println);
    }

    public static void flatMapStream() {
        Stream<List<Integer>> stream = Stream.of(Arrays.asList(1, 2), Arrays.asList(3, 4, 5));
        stream.flatMap(list -> list.stream())
                .forEach(System.out::println);
    }

}
